/**
 * Copyright (c) 2009-2011, chunquedong(YangJiandong)
 * 
 * This file is part of ChunMap project
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
 * 
 * History:
 *     2010-05-05  Jed Young  Creation
 */
package chunmap.raster.gmap;

import java.util.List;

import chunmap.model.elem.Envelope;
import chunmap.raster.Tile;
import chunmap.view.Renderer;
import chunmap.view.layer.AbstractLayer;
import chunmap.view.render.Symbol;

public class GMLayer extends AbstractLayer{
	protected GMDataSource dataSource = new GMDataSource();
	
	public GMLayer(String url){
		super();
		dataSource.conn.rootUrl=url;
	}
	public GMLayer(){
		super();
	}

    public @Override Envelope getEnvelop()
    {
        return dataSource.getEnvelop();
    }

    public void setBufferPath(String path)
    {
        dataSource.conn.setBufferPath(path);
    }

	@Override
	protected void subRender(Symbol smb, int i, Renderer r) {
		List<GMTile> tileSet = dataSource.getTileSet(r.getViewEnvelop(), r.getScale());
        for (Tile t : tileSet)
        {
            r.draw(t, smb, 0);
        }
	}
}